<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>密码修改</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
	<ol class="breadcrumb" style="margin-bottom:5px;">
		<li><a href="#">安全管理</a></li>
		<li class="active">密码修改</li>
	</ol>
<body>
	<form action="LogDoUpd.do" method="post" style="padding-left:300px">
		<div class="form-group">
			<label for="pwt1">当前密码</label>
			<input type="password" class="form-control" id="pwt1" name="pwt1" placeholder="请输入当前密码" style="width:300px">
		</div>
		<div class="form-group">
			<label for="pwt2">新密码</label>
			<input type="password" class="form-control" id="pwt2" name="pwt2" placeholder="请输入新密码" style="width:300px">
		</div>
		<div class="form-group">
			<label for="pwt3">新密码</label>
			<input type="password" class="form-control" id="pwt3" name="pwt3" placeholder="请再次输入新密码" style="width:300px">
		</div>
		  <button type="submit" class="btn btn-default" id="bt1">确认</button>
	</form>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-3.3.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>

<script type="text/javascript">
	document.getElementById("bt1").onclick=function(){
		var pwt1=document.getElementById("pwt1").value;//原密码
		var pwt2=document.getElementById("pwt2").value;//新密码1
		var pwt3=document.getElementById("pwt3").value;//新密码2
		//var type=/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d){3,}$/;//正则表达式
		//Pattern p=Pattern.compile(regex);
		//Matcher m=p.matcher(password);
		//?=pattern  在任何匹配pattern的字符串开始处匹配查找字符串，该匹配不需要获取供以后使用
		//也就是说，在一个匹配发生后，在最后一次匹配之后立即开始下一次匹配的搜索，而不是从包含预查的字符之后开始
		var regex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{3,}$/;
		if(pwt1.length==0 || pwt2.length==0 || pwt3.length==0){//原密码和修改密码都不为空
			alert("密码不能为空，请重新输入密码！");
			return false;
		}else if(pwt2==pwt3 && pwt2.match(regex) && pwt3.match(regex)){
			return confirm("你真的要修改密码吗？请三思哦！");
		}else{
			alert("密码至少包含一个数字、一个大写字符和一个小写字符");
			return false;
		}
	}
</script>
</body>
</html>